﻿
using MyFloridaHouse.libSvOpenDistricts.Dialogs;
using MyFloridaHouse.libSvCommonUtilities;
using MyFloridaHouse.libSvOpenDistricts.SummaryDataGrid;
namespace MyFloridaHouse.libSvOpenDistricts.ViewModel
{
    public partial class ViewModelBase
    {
        public DistrictCustomizationDlg districtCustomizationDlg;
    
        private bool CmdPrefDistrictCanExecute(object parameter)
        {
            return ((!isDialogOpen) & (districtPlan.districtCount > 0));
        }

        private void CmdPrefDistrictExecute(object parameter)
        {
            ReserveDialog(CmdPrefCriteria);
            districtCustomizationDlg = new DistrictCustomizationDlg(OnMemberPropertyChanged, DisplayPanelForDialogs);
            districtCustomizationDlg.Start(CmdPrefDistrictGetDistrictCustomizationDone);
            districtCustomizationDlg.targetPopulation = Constants.TOTAL_POPULATION_TO_BE_APPORTIONED / districtPlan.districtCount;

        }

        private void CmdPrefDistrictGetDistrictCustomizationDone(bool result)
        {
            if (result)
            {
                SummaryDataGridManager.SetTargetPopulation(districtCustomizationDlg.targetPopulation);
            }
            ReleaseDialog(CmdPrefDistrict);
        }

    }
}
